import { functionCommon, requestCommon } from "@whzhuke/common"

export default {
  upload: (params: any) => {
    const FormPost = new FormData()
    Object.keys(params).forEach(key => {
      const data = params[key]
      if (data instanceof Blob) {
        FormPost.append(key, data)
      } else {
        FormPost.append(key, data.toString())
      }
    })
    return requestCommon.post<any,any>({
      url: `${functionCommon.requestHost("api")}/v1/m/file`,
      params: FormPost,

      headers: {
        "Content-Type": "multipart/form-data;"
      }
    })
  }
}
